#include <gtest/gtest.h>
#include <string>

#include "address-book.h"
#include "person.h"

/* Ex 4.4 & 4.5: These tests no longer fail because of user-defined
                 copy constructor and assignment operator.


   Ex 4.2: Test to see that copy does not share state with the
           original
*/
TEST(AddressBookEntry, copyDoesNotShareStateWithOriginal)
{
    Person john("john", 20);
    AddressBookEntry entry1(john,"john_pic" );
    AddressBookEntry entry2 = entry1;

    entry2.setImageName("entry2_pic");

    EXPECT_NE( entry1.getImageName(), entry2.getImageName() );
}

/* Ex 4.3: Test to see that an object is independent from the object
           it is assigned from after assigning - expected to fail
*/
TEST(AddressBookEntry, assignedObjectIndependentFromAssignee)
{
    Person john("john", 21);
    Person jane("jane", 26);
    AddressBookEntry entry1( john,"john_pic" );
    AddressBookEntry entry2( jane,"jane_pic");

    entry1 = entry2;

    entry2.setImageName("entry2_pic");

    EXPECT_TRUE( entry2.getImageName() == "entry2_pic");
}


